<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">
        <mytest :msg="parentMsg" :setwidth="500"></mytest>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        // 全局组件 - 子组件
        // component组件
        Vue.component("mytest",{
            // 接收值
            props:["msg","setwidth"],
            template:"<div :style='setStyle'>接收的数据：{{msg}}</div>",
            // 计算属性
            computed:{
                setStyle(){
                    return `width:${this.setwidth}px`
                }
            }
        })
        let vm = new Vue({
            el:"#box",
            data:{
                parentMsg:"父的数据"
            }
        })
    </script>
</body>
</html>